<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"
%><%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"
%><%@ taglib prefix="security" uri="http://www.springframework.org/security/tags"
%><%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"
%><%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"
%>
<head>
    <title><fmt:message key="coupon" /></title>
</head>
<body>
	<script language="JavaScript">
	<!--
		dojo.require("dojo.date.locale");
	//-->
	</script>
    <h1><fmt:message key="coupon" /></h1>
    <c:url var="createUrl" value="/domain/coupon/create"/>
    <form:form action="${createUrl}" id="couponForm" modelAttribute="couponForm" enctype="multipart/form-data">
        <form:errors cssClass="error"/>
        <table>
            <tbody>
                <tr>
                    <th><fmt:message key="coupon_name" /></th>
                    <td>
                        <form:input path="coupon.name"/>
                        <script type="text/javascript">
                            Spring.addDecoration(new Spring.ElementDecoration({
                                elementId : "coupon.name",
                                widgetType : "dijit.form.ValidationTextBox",
                                widgetAttrs : {
                                    required : true
                                }
                            }));
                        </script>
                        <form:errors cssClass="error" path="coupon.name"/>
                    </td>
                </tr>
                <tr>
                    <th><fmt:message key="coupon_description" /></th>
                    <td>
                        <form:input path="coupon.description"/>
                        <script type="text/javascript">
                            Spring.addDecoration(new Spring.ElementDecoration({
                                elementId : "coupon.description",
                                widgetType : "dijit.form.SimpleTextarea",
                                widgetAttrs : {
                                    required : false
                                }
                            }));
                        </script>
                        <form:errors cssClass="error" path="coupon.description"/>
                    </td>
                </tr>
                <tr>
                    <th><fmt:message key="coupon_active" /></th>
                    <td>
                        <form:input path="coupon.active"/>
                        <script type="text/javascript">
                            Spring.addDecoration(new Spring.ElementDecoration({
                                elementId : "coupon.active",
                                widgetType : "dijit.form.CheckBox",
                                widgetAttrs : {
                                    checked: ${couponForm.coupon.active != null ? couponForm.coupon.active : false}
                                }
                            }));
                        </script>
                        <form:errors cssClass="error" path="coupon.active"/>
                    </td>
                </tr>
                <tr>
                    <th><fmt:message key="coupon_startDate" /></th>
                    <td>
                        <form:input path="coupon.startDate"/>
                        <script type="text/javascript">
                            Spring.addDecoration(new Spring.ElementDecoration({
                                elementId : "coupon.startDate",
                                widgetType : "dijit.form.DateTextBox",
                                widgetAttrs : {
                                    required : false,
									datePattern : "yyyy-MM-dd"
                                }
                            }));
                        </script>
                        <form:errors cssClass="error" path="coupon.startDate"/>
                    </td>
                </tr>
                <tr>
                    <th><fmt:message key="coupon_endDate" /></th>
                    <td>
                        <form:input path="coupon.endDate"/>
                        <script type="text/javascript">
                            Spring.addDecoration(new Spring.ElementDecoration({
                                elementId : "coupon.endDate",
                                widgetType : "dijit.form.DateTextBox",
                                widgetAttrs : {
                                    required : false,
									datePattern : "yyyy-MM-dd"
                                }
                            }));
                        </script>
                        <form:errors cssClass="error" path="coupon.endDate"/>
                    </td>
                </tr>
            </tbody>
            <tfoot>
                <tr>
                    <td colspan="2">
                        <div class="buttons">
                            <button id="saveButton" class="ok" type="submit"><fmt:message key="label.form.submit"/></button>
                            <script type="text/javascript">
                                Spring.addDecoration(new Spring.ValidateAllDecoration({
                                    elementId:'saveButton',
                                    event:'onclick'
                                }));
                            </script>
                        </div>
                    </td>
                </tr>
            </tfoot>
        </table>
    </form:form>
</body>
